package nl.saxion.dbi.model;

public enum Type
{

	integer
	{
		@Override
		public boolean isValid(String value)
		{
			if (value == null)
			{
				return true;
			}

			try
			{
				Integer.parseInt(value);
				return true;
			}
			catch (Exception e)
			{
				return false;
			}
		}
	},
	bool
	{
		@Override
		public boolean isValid(String value)
		{
			if ("true".equals(value) || "false".equals(value) || value == null)
			{
				return true;
			}
			return false;
		}
	},
	string
	{
		@Override
		public boolean isValid(String value)
		{
			return true;
		}
	};

	public abstract boolean isValid(String value);

	public static boolean isValidType(String type)
	{
		try
		{
			Type.valueOf(type);
			return true;
		}
		catch (Exception e)
		{
			return false;
		}
	}
}
